package com.fusion.ui.windows;

import com.fusion.core.interactions.PleaseForwardInvitationInteraction;
import com.fusion.core.node.FriendManager;
import com.fusion.ui.UISubsystem;
import com.stendahls.XUI.XUIDialog;
import com.stendahls.ui.JHtmlLabel;


import javax.swing.*;
import java.awt.event.ActionEvent;

/**
 * @author SwethaShivakumar 
 * Project: fusion
 * Date: Mar 12, 2009
 * URL: http://fusionwiki.co.cc
 * Mail Me At: shiva@fusionproject.co.cc
 */
public class ForwardInvitationDialog extends XUIDialog {
    private static final long serialVersionUID = 1L;
	private JCheckBox alwaysAllowInvite;
    private boolean pressedYes = false;


    public ForwardInvitationDialog(UISubsystem ui, PleaseForwardInvitationInteraction pmi) throws Exception {
        super(ui.getMainWindow());

        init(ui.getRl(), ui.getRl().getResourceStream("xui/forwardinvitation.xui.xml"));

        FriendManager fm = ui.getCore().getFriendManager();
        String from = fm.nicknameWithContactPath(pmi.getFromGuid());
        String to = fm.nicknameWithContactPath(pmi.getToGuid());

        ((JHtmlLabel)xui.getComponent("label")).setText(from+" wants to connect to "+to+". These two users are not connected right now. You are the connection between them.<p>Do you want to allow "+from+" to connect to "+to+"?");

        alwaysAllowInvite = (JCheckBox)xui.getComponent("alwaysAllowInvite");

        setDefaultCloseOperation(DISPOSE_ON_CLOSE);

        display();
    }

   public boolean hasPressedYes() {
        return pressedYes;
    }

    public boolean alwaysAllowInvite() {
        return alwaysAllowInvite.isSelected();
    }

    public void EVENT_yes(ActionEvent a) throws Exception {
        pressedYes = true;
        dispose();
    }

    public void EVENT_no(ActionEvent a) throws Exception {
        dispose();
    }
}
